/*
 * Copyright (c) 2021 Extreme Vision Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef EV_JI_H_
#define EV_JI_H_

#include "ji_types.h"
#include "ji_error.h"

#ifdef __cplusplus
extern "C"
{
#endif

	/**
 * @brief SDK initialization interface.The authorization function can be implemented in the function
 * @param[in] argc Number of parameters
 * @param[in] argv Parameter array
 * @return JiErrorCode  - operation result
 */
JiErrorCode ji_init(int argc, char **argv);

/**
 * @brief SDK de initialization function
 * @return void         - operation result
 */
void ji_reinit();

/**
 * @brief Create an algorithm predictor instance.
 * 
 * @param[in] pdtype - the predictor type
 * @return void*     - the pionter of algorithm predictor instance
 */
void* ji_create_predictor(JiPredictorType pdtype);

/**
 * @brief Free an algorithm predictor instance.
 * 
 * @param[in] predictor - the predictor instance pointer
 * @return void         - operation result
 */
void ji_destroy_predictor(void *predictor);


/**
 * @brief set callback function
 * 
 * @param[in] predictor - the predictor instance pointer
 * @param[in] callback  - the the callback fucntion
 * @return JiErrorCode         - operation result
 */
JiErrorCode ji_set_callback(void *predictor, JiCallBack callback);

/**
 * @brief Picture analysis asynchronous interface.
 * 
 * @param[in]  predictor  - predictor instance
 * @param[in]  pInFrames  - input picture information array
 * @param[in]  nInCount   - picture information array size
 * @param[in]  args       - custom algorithm parameters，such as roi
 * @param[in]  userData   - user data for callbcak
 * @return JiErrorCode    - operation result
 */

JiErrorCode ji_calc_image_asyn(void* predictor, const JiImageInfo* pInFrames, const unsigned int nInCount, const char* args, void *userData);

/**
 * @brief Picture analysis synchronous interface.
 * 
 * @param[in]  predictor  - predictor instance
 * @param[in]  pInFrames  - input picture information array
 * @param[in]  nInCount   - picture information array size
 * @param[in]  args       - custom algorithm parameters，such as roi
 * @param[out] pOutFrames - output picture information array
 * @param[out] nOutCount  - output picture information array size
 * @param[out] event      - report algorithm analysis result event
 * @return JiErrorCode    - operation result
 */
JiErrorCode ji_calc_image(void* predictor, const JiImageInfo* pInFrames, const unsigned int nInCount, const char* args, 
						JiImageInfo **pOutFrames, unsigned int & nOutCount, JiEvent &event);

/**
 * @brief Update algorithm configuration.
 *
 * @param[in] predictor - predictor instance
 * @param[in] args      - custom algorithm parameters，such as roi
 * @return JiErrorCode  - operation result
 */
JiErrorCode ji_update_config(void *predictor, const char *args);

/**
 * @brief Get the sdk version.
 *
 * @param[out] pVersion - the current version
 * @return JiErrorCode  - operation result
 */
JiErrorCode ji_get_version(char *pVersion);

/**
 * @brief Face collection interface
 *
 * @param[in] predictor - predictor instance
 * @param[in] imgPath   - face image path
 * @param[in] libId     - face depository number
 * @return JiErrorCode  - operation result
 */
JiErrorCode ji_face_insert(void *predictor, const char *imgPath, const int libId);

/**
 * @brief Face delete interface
 *
 * @param[in] predictor - predictor instance
 * @param[in] faceIds   - face number array
 * @param[in] libId     - face depository number
 * @return JiErrorCode  - operation result
 */
JiErrorCode ji_face_delete(void *predictor, const char *faceId, const int libId);

/**
 * @brief Face update interface
 *
 * @param[in] predictor - predictor instance
 * @param[in] libId     - face depository number
 * @param[in] imgPath   - face image path
 * @return JiErrorCode  - operation result
 */
JiErrorCode ji_face_update(void *predictor, const int libId, const char *imgPath);

/**
 * @brief Initialize the face depository, including whitelist and blacklist depository.
 * 
 * @param[in] predictor - predictor instance
 * @param[in] whitePath - the whitelist depository path
 * @param[in] blackPath - the blacklist depository path
 * @return JiErrorCode  - operation result
 */
JiErrorCode ji_face_init(void *predictor, const char *whitePath, const char *blackPath);

/**
 * @brief Export face depository to local path.
 * 
 * @param[in] predictor - predictor instance
 * @param[in] outPath   - local save path of face depository
 * @param[in] libId     - face depository number
 * @return JiErrorCode  - operation result
 */
JiErrorCode ji_face_exportDB(void *predictor, const char *outPath, const int libId);

#ifdef __cplusplus
}
#endif

#endif // EV_JI_H_
